// 1. 引用创建路由需要的组件
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

// 2. 配置系统所有路由页面
const routes: Array<RouteRecordRaw> = [
  // 登录页
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/login/login.vue')
  },
  // 首页
  {
    path: '/',
    name: 'Layout',
    component: () => import('../views/layout/index.vue'),
    redirect: '/users',
    children: [
      {
        path: 'users',
        name: 'users',
        component: () => import('@/views/users/index.vue')
      },
      {
        path: 'reports',
        name: 'reports',
        component: () => import('@/views/reports/index.vue')
      },
      {
        path: 'rights',
        name: 'rights',
        component: () => import('@/views/rights/index.vue')
      },
      {
        path: 'roles',
        name: 'roles',
        component: () => import('@/views/roles/index.vue')
      }
    ]
  }
]

// 3. 创建路由实例
const router = createRouter({
  history: createWebHistory(process.env.BASE_URL), // 使用 history 模式 hash模式（createWebHashHistory）
  routes
})

// 4. 声明，为路由提供外部引用的入口
export default router
